package com.suntimes.guangjiegou.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.suntimes.cl.util.CLLog;
import com.suntimes.guangjiegou.GuangJieGouApplication;
import com.suntimes.guangjiegou.activity.MainActivity;

public abstract class BaseFragment extends Fragment {
	
	public static final String TAG = "BaseFragment";
	
	private NavigationFragment mNavigationFragment;
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = loadView(inflater, container, savedInstanceState);
		return view;
	}
	
	protected abstract View loadView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState);
	
	@Override
	public void onDestroy() {
		CLLog.i(TAG, "onDestroy >> " + this.getClass().getName());
		super.onDestroy();
	}

	@Override
	public void onDestroyView() {
		CLLog.i(TAG, "onDestroyView >> " + this.getClass().getName());
		// TODO Auto-generated method stub
		super.onDestroyView();
	}

	@Override
	public void onDetach() {
		CLLog.i(TAG, "onDetach >> " + this.getClass().getName());
		// TODO Auto-generated method stub
		super.onDetach();
	}

	@Override
	public void onPause() {
		CLLog.i(TAG, "onPause >> " + this.getClass().getName());
		// TODO Auto-generated method stub
		super.onPause();
	}

	@Override
	public void onResume() {
		CLLog.i(TAG, "onResume >> " + this.getClass().getName());
		// TODO Auto-generated method stub
		super.onResume();
	}

	@Override
	public void onStart() {
		CLLog.i(TAG, "onStart >> " + this.getClass().getName());
		// TODO Auto-generated method stub
		super.onStart();
	}

	@Override
	public void onStop() {
		CLLog.i(TAG, "onStop >> " + this.getClass().getName());
		// TODO Auto-generated method stub
		super.onStop();
	}

	public MainActivity getMainActivity() {
		return (MainActivity) getActivity();
	}

	public GuangJieGouApplication getApplication() {
		GuangJieGouApplication application = (GuangJieGouApplication) getActivity()
				.getApplication();
		return application;
	}

	public NavigationFragment getNavigationFragment() {
		return mNavigationFragment;
	}

	public void setNavigationFragment(NavigationFragment navigationFragment) {
		this.mNavigationFragment = navigationFragment;
	}

	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
			return false;
		}
		return false;
	}

}
